function Out = lmafit(Prob,opts)
%
% Copyright(c) 2009 Yin Zhang
%

m = Prob.size(1);
n = Prob.size(2);
k = Prob.rank;

%fprintf('\n...LMafit...\n')
switch Prob.type
    case 'MC';
        [X,Y,Out] = lmafit_mc(m,n,k,Prob.known,Prob.data,opts);
        Out.X = X; Out.Y = Y;
    case 'SMS'
        [X,Y,Z,Out] = lmafit_sms(m,n,k,Prob.A,Prob.mu,opts); 
        Out.X = X; Out.Y = Y; Out.Z = Z;
    case 'MCS';
        if isstruct(Prob.Amap)
            L  = Prob.Amap.times;
            Lt = Prob.Amap.trans;
        else
            L  = @(x) Prob.Amap(x,1);
            Lt = @(y) Prob.Amap(y,2);
        end
        bnrm = max(1,norm(Prob.b,inf));
        [X,Y,Out] = lmafit_mcs(m,n,k,L,Lt,Prob.b/bnrm,Prob.rho,opts);
        Out.X = bnrm*X; Out.Y = Y;
    otherwise; error('No such a Prob.type')
end


